import { type PageDataModel } from "@/model/page-data-model";
import { type UserModel } from "@/model/user-model";
import request from "@/utils/request";
import { type UserListSearchModel } from "@/views/user/list/avue-options";

const UserAPI = {
  /**
   * @description 录入一个客户
   * @param data 客户信息
   */
  add(data: UserModel) {
    return request<any, any>({
      url: `/admin/user/addUser`,
      method: "post",
      data,
    });
  },

  /**
   * @description 编辑
   * @param data 客户信息
   */
  edit(data: UserModel) {
    return request<any, any>({
      url: `/admin/user/editUser`,
      method: "post",
      data,
    });
  },

  /**
   * 获取用户分页列表
   *
   * @param queryParams 查询参数
   */
  getPage(data: UserListSearchModel) {
    return request<any, PageDataModel<UserModel[]>>({
      url: `/admin/user/userList`,
      method: "post",
      data,
    });
  },

  /**
   * 获取用户分页列表
   * @param id 用户id
   * @returns 用户详情
   */
  detail(id: number | string) {
    return request<any, UserModel>({
      url: `/admin/user/userDetail`,
      method: "post",
      data: { id },
    });
  },

  /**
   * @description 删除用户
   * @param id 用户ID
   */
  delete(id: number | string) {
    return request<any, any>({
      url: `/admin/user/delUser`,
      method: "post",
      data: { id },
    });
  },

  /**
   * @description 客户地图分布数据列表
   */
  mapData() {
    return request<any, any>({
      url: "/admin/user/userMapList",
      method: "post",
    });
  },

  /**
   * @description 获取改造用户统计花名册
   * @param data 改造用户统计花名册
   */
  getRevampUserList(data: any) {
    return request<any, any>({
      url: "/admin/user/projectList",
      method: "post",
      data,
    });
  },
};

export default UserAPI;
